﻿/*
* 作 者: 王冬冬
* 公 司: 墨宇天城
* 创建时间: 2016/3/23 16:15:32
* 说明:  
*/

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;

public class ImgRandom : MonoBehaviour
{
    public List<Sprite> SpriteList;
    [HideInInspector]
    public Image image;
    void Awake()
    {
        image = this.transform.GetComponent<Image>();
    }
    IEnumerator Start()
    {
        while(true)
        {
            yield return new WaitForSeconds(5f);
            image.overrideSprite = SpriteList[randomImg()];
        }
    }
    public int randomImg()
    {
        return Random.Range(0, SpriteList.Count);
    }
}